#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_exercise.py
# author:wmf
# datetime:2021/3/13 14:58
# software: PyCharm
'''
this is function description
'''
# import module your need

#定义元组, 进行基本的操作(元组的基本运算, 元素的输出, 内置函数的使用);
#定义一个元组, 来保存成绩, 输出最高分;

list1 = ['hello','world']
tup1 = ('Google', 'Runoob', 1997, 2000)
tup2 = (1, 2, 3, 4, 5, 6, 7 )
print(type(tup1))
print(len(tup1))
print(tup1+tup2)
print(('Hi!',)*4)
print(3 in tup2)

for x in tup1:
    print(x,end=' ')

print('\n')

print(max(tup2))
print(min(tup2))
print(tuple(list1))

print('\n')

from random import randint

score = [randint(60,100) for _ in range(10)]
score = tuple(score)
for x in score:
    print(x,end=' ')

print('\n')
max_score = max(score)
print('最高分是:%d'%max_score)

print('\n')

#定义一个字典,存放某个同学的信息(学号,姓名,班级,年龄);   再定义另外一个字典,存放5个同学的学号,姓名信息;
#通过键来访问相应的数据; 或者整体输出

dict1 = {'num':123,'name':'Tom','class':'软件1902','age':18}
dict = {'01':{'num':111,'name':'Bob'},
        '02':{'num':222,'name':'Candy'},
        '03':{'num':333,'name':'Jackson'},
        '04':{'num':444,'name':'Coco'},
        '05':{'num':555,'name':'Linda'}
        }
print(dict1['name'])
print(dict1)
print(dict['03'])
print(dict)

print('\n')

#字典的元素的增加, 修改, 删除;
#并观察输出;

dict1['age']=19
dict1['school']='ncepu'

print(dict1)

del dict1['num']
print(dict1)

dict1.clear()
print(dict1)

print('\n')

#定义一个集合类型的变量(用2种方法初始化),然后进行相应的 元素的操作;
basket = {'apple','orange','apple','pear','orange','banana'}
print(basket)

a = set('abracadabra')
b = set('alacazam')
print(a)
print(a-b)
print(a|b)
print(a&b)
print(a^b)

print('-'*20)

a = {x for x in 'abracadabra' if x not in 'abc'}
print(a)

thisset = set(("Google","Runoob","Taobao"))
thisset.add("Facebook")
thisset.update({1,3})
print(thisset)
thisset.update([4,5],[6,7])
print(thisset)
thisset.remove("Taobao")
print(thisset)

thisset.discard("Facebook")
print(thisset)
x = thisset.pop();
print(x)

print("Google" in thisset)

